package org.syx.droid.telnet.test;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

/**
 * This is the main activity. It is supposed to print out what is sent by
 * telnet. To do this, a {@link android.os.Handler} will be implemented
 * eventually, which will be responsible for updating the
 * {@link android.widget.TextView}.
 * 
 * @author cesardepadua
 * 
 */
public class SocketTestActivity extends Activity {
	
	/**
	 * This is solely for Logcat convenience.
	 */
	private static final String TAG = "SocketTestActivity";
	
	/**
	 * This is the area in which the telnet commands will be printed.
	 */
	private TextView textView;

	/**
	 * Called when the activity is first created. Sets {@link textView}, then
	 * calls the {@link MasterController} service to setup the networking
	 * module.
	 */
	@Override
	public void onCreate (Bundle savedInstanceState) {
	
		Log.d (TAG, "Starting SocketTest");
		super.onCreate (savedInstanceState);
		setContentView (R.layout.main);
		
		this.textView = (TextView) this.findViewById (R.id.text);
		
		TextAppender.Factory.initialize (textView);
		
		this.startService (new Intent ().setClass (
				this.getApplicationContext (), MasterController.class));
		
		Log.d (TAG, "Done initializing");
	}
}
